<?php
  
    ob_start();
    $pageContent = '';
    getContent();
    function getContent()
    {
        global $pageContent;
  
        $pageContent = ob_get_contents();
        ob_clean();
  
        ?>
<!DOCTYPE html>
<html lang="fr">
<body>
<a href="test2.php">test2</a>
<?php
    echo " -- test : ".$_SESSION['var'].$pageContent;
?>
</body>
</html>
<?php
        //return $var;
    }
  
    ob_end_flush();
    $_SESSION['var'] = "";
?>